﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __6A8002CD_5650_4187_8CC9_66DCBF9501AF__
#define __6A8002CD_5650_4187_8CC9_66DCBF9501AF__

#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos
{
    // 
    // event_impl
    // 
    class event_impl : public xos_stl::mem_item< release_impl< event_impl >, thread_lock >,
        public i_event
    {
    public:
        typedef release_impl< event_impl > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //

        static int get_addr( POOL *** pppPool, LIST *** pppList );

    public:
        event_impl();
        ~event_impl();

    protected:
        int m_nWriteNum;
        // 0 : read; 
        // 1 : write
        int m_nPipe[2];

    public:
        int init();
        int term();

    public:
        // 
        // wait for event ...
        // 
        unsigned long wait( unsigned long ulMilliseconds );
        // 
        // set event
        // 
        int set_event();
    };
} // xos

#endif // __6A8002CD_5650_4187_8CC9_66DCBF9501AF__
